package Test3;

import java.awt.*;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 * 功能描述：
 *
 * @Author: ygq
 * @Date: 2021/12/12 14:49
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int num = Integer.valueOf(s);
        double[][] points = new double[num][2];
        for (int i = 0; i < num; i++) {
            String s1 = scanner.nextLine();
            String[] s2 = s1.split(" ");
            points[i][0] = Double.valueOf(s2[0]);
            points[i][0] = Double.valueOf(s2[1]);
        }
        Arrays.sort(points, new Comparator<double[]>() {
            @Override
            public int compare(double[] o1, double[] o2) {
                if (o1[0]==o2[0]){
                    if(o2[1]>o1[1]) return 1;
                    if(o2[1]<=o1[1]) return -1;
                }
                else {
                    if (o1[0]-o2[0]>=0) return -1;

                }
                return 1;
            }
        });
        Arrays.toString(points);

    }

}
